<?php
class mod_news extends core_modbase {
	
	private function UpdtNews()
	{
		$news = new SQL('news');
		$news
			->where(array(
				'news' => array(
					'news_state' => 'programed',
					'news_time' => array('op' => '>', 'value' => date('Y-m-d H:i:s'))
				)
			))
			->set(array('news_state' => 'active'));
	}
	
	function PAGE_index ()
	{
		$this->UpdtNews();
		
		$this->template->assign('title', core_settings::Get('sitename') . ' :: Accueil');
		$news = new SQL(array('T' => 'news'));
		$newslist = $news
			->where(array('news_state' => 'active'))
			->select('*', ' ORDER BY T.news_time DESC LIMIT 5');
		foreach ($newslist as $news)
		{
			$this->template->block('news', array(
				'title' => $news->news_title,
				'content' => $news->news_content,
			));
		}
		$this->display('accueil.tpl');
	}
}
